package cn.enilu.flash.enums.body;

import cn.enilu.flash.enums.OptionObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author Spark
 * @Date Created in (2019/10/31 15:02)
 * @Version v1.0
 * @Modify
 **/
public enum ProvinceArea implements OptionObject {
    A(0, "A"),
    B(1, "B"),
    C(2, "C"),
    D(3, "D"),
    E(4, "E"),
    F(5, "F"),
    G(6, "G"),
    H(7, "H"),
    I(8, "I"),
    J(9, "J"),
    K(10, "K"),
    L(11, "L"),
    M(12, "M"),
    N(13, "N"),
    O(14, "O"),
    P(15, "P"),
    Q(16, "Q"),
    R(17, "R"),
    S(18, "S"),
    T(19, "T"),
    U(20, "U"),
    V(21, "V"),
    W(22, "W"),
    X(23, "X"),
    Y(24, "Y"),
    Z(25, "Z")
    ;

    private int code;
    private String text;


    ProvinceArea(int code, String text){
        this.code = code;
        this.text = text;
    }

    public static Map<Integer, String> toMap = new HashMap<Integer, String>();

    static {
        ProvinceArea[] types = ProvinceArea.values();
        for (ProvinceArea type : types) {
            toMap.put(type.getCode(), type.getText());
        }
    }

    public static String valueOfCode(int code) {
        ProvinceArea[] bts = ProvinceArea.values();
        for (ProvinceArea bt : bts) {
            if(bt.getCode() == code){
                return bt.getText();
            }
        }
        return "--";
    }

    @Override
    public int getCode() {
        return this.code;
    }

    @Override
    public String getText() {
        return this.text;
    }

    @Override
    public boolean compare(int code){
        if(this.getCode() == code){
            return true;
        }
        return false;
    }
}
